package com.example.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @BelongsProject："smart-property"
 * @BelongsPackage："com.example.config"
 * @CreateTime："2022-11-21 11:20"
 * @Description：评论config
 * @Author：LK
 */
@Configuration
public class CommentMQConfig {

    // 发送评论
    public static final String SMART_JIAOHUANJI_NAME = "wlj.smart.jiaohuanji.name";
    public static final String SMART_QUEUE_NAME = "wlj.smart.queue.name";

    /**
     * @description:交换机
     * @author: lk
     * @date: 2022/11/21 11:26
     * @return: org.springframework.amqp.core.DirectExchange
     **/
    @Bean
    DirectExchange jiaohuanji(){
        return ExchangeBuilder.directExchange(CommentMQConfig.SMART_JIAOHUANJI_NAME).build();
    }

    /**
     * @description:队列
     * @author: lk
     * @date: 2022/11/21 11:26
     * @return: org.springframework.amqp.core.DirectExchange
     **/
    @Bean
    Queue duilie(){
        return QueueBuilder.durable(CommentMQConfig.SMART_QUEUE_NAME).build();
    }

    /**
     * @description:绑定
     * @author: lk
     * @date: 2022/11/21 11:27
     * @return: org.springframework.amqp.core.Binding
     **/
    @Bean
    Binding bangding(){
        return BindingBuilder.bind(duilie()).to(jiaohuanji()).with("pinglun1");
    }
}
